#if UNITY_EDITOR
using System.IO;
using UnityEditor;
using UnityEngine;

namespace JH
{
    /// <summary>
    /// 使用快捷键，快速打开常用路径
    ///  Alt + Shift + 1  ->  打开StreamingAssets路径
    ///  Alt + Shift + 2  ->  打开PersistentData路径
    ///  Alt + Shift + 3  ->  打开DataPath路径
    ///  Alt + Shift + 4  ->  打开TemporaryCache路径
    /// </summary>
    public static class QuickPathAccessHelper
    {
        [MenuItem("Tools/JH/快速访问常用路径/打开 StreamingAssets  #&1", false, 1)]
        public static void OpenStreamingAssets()
        {
            OpenFolder(Application.streamingAssetsPath);
        }

        [MenuItem("Tools/JH/快速访问常用路径/打开 PersistentData  #&2", false, 2)]
        public static void OpenPersistentData()
        {
            OpenFolder(Application.persistentDataPath);
        }

        [MenuItem("Tools/JH/快速访问常用路径/打开 DataPath  #&3", false, 3)]
        public static void OpenDataPath()
        {
            OpenFolder(Application.dataPath);
        }

        [MenuItem("Tools/JH/快速访问常用路径/打开 TemporaryCache  #&4", false, 4)]
        public static void OpenTemporaryCache()
        {
            OpenFolder(Application.temporaryCachePath);
        }
        
        public static void OpenFolder(string folderPath)
        {
            if (Directory.Exists(folderPath))
            {
                EditorUtility.RevealInFinder(folderPath);
            }
            else
            {
                Debug.LogWarning($"Folder does not exist: {folderPath}");
            }
        }
    }
}
#endif